package com.appbee.core.client.ui;

import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.Widget;

public class RegionPanel extends ResizeComposite implements AcceptsOneWidget
{
	private LayoutPanel panel = new LayoutPanel();
	private IsWidget widget;
	
	public RegionPanel()
	{
		initWidget(panel);
	}
	
	@Override
	public void setWidget(Widget w)
	{
		
		if(widget!=null)
		{
			panel.remove(widget);
		}
		widget = w;
		if(w!=null)
		{
			panel.add(widget);
			panel.forceLayout();
		}
	}
	
	public Widget getWidget()
	{
		return asWidgetOrNull(widget);
	}
	
	@Override
	public void setWidget(IsWidget w)
	{
		setWidget(asWidgetOrNull(w));
	}
	
	public void addStyleNames(String style)
	{
		panel.addStyleName(style);
	}
	
	public void setStyleName(String style)
	{
		panel.setStyleName(style);
	}
	
	
}
